package com.egao.orderB.biz.impl;

import com.egao.common.core.damon.constant.UserConstant;
import com.egao.common.core.damon.results.BaseDao;
import com.egao.common.core.damon.results.PageResult2;
import com.egao.common.core.damon.utils.Utils;
import com.egao.common.core.web.JsonResult;
import com.egao.common.system.entity.User;
import com.egao.orderB.biz.OceanBiz;
import com.egao.orderB.entity.Ocean;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.jdbc.core.SingleColumnRowMapper;
import org.springframework.jdbc.core.namedparam.SqlParameterSource;
import org.springframework.jdbc.support.GeneratedKeyHolder;
import org.springframework.stereotype.Repository;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 *
 * 数据层实现类
 * @author : Doman
 * @date : 2021-09-06 16:20:23
 * @version ：1.0
 */
@Repository
public class OceanBizImpl extends BaseDao implements OceanBiz {

	@Override
	public JsonResult list(PageResult2<T> page, Ocean ocean, User loginUser) throws Exception {
		Map<String, String> map  = new HashMap<String, String>();
		RowMapper<Ocean> rm = new BeanPropertyRowMapper<Ocean>(Ocean.class);
		StringBuffer sql = new StringBuffer("select ");
		if (Utils.isNotEmpty(ocean.getKeywords())) {
			sql.append(" distinct ");
		}
    sql.append("o.id,o.organization_id,o.pre_configuration_id,o.customer_id");
    sql.append(",o.customer,o.contacts,o.contacts_phone,o.start_port");
		sql.append(",o.end_port,o.box_type,o.go_ship_day,o.vessel");
		sql.append(",o.voyage,o.air_route,o.bill_of_lading,o.booking_agent,o.ship");
		sql.append(",o.deliver,o.box_num,o.sealno,o.cut_off_day,o.cut_off_annex,o.cut_order_annex,o.finish_ocean_day,o.customer_remark");
		sql.append(",o.plat_remark,o.finance_remark,o.state,o.book_annex");
		sql.append(",o.cus_plan_deposit,o.pre_storage_deposit,o.settlement_date,o.payment_type");
		sql.append(",o.release_annex,o.salesmanId,o.salesman,o.operatorId");
		sql.append(",o.operator,o.create_time,o.create_user,o.update_time");
		sql.append(",o.update_user");
		sql.append(",boa.bill_id,boa.apply_id");
    sql.append(",sogzn.organization_name organizationName,suser.nick_name createName ");
    sql.append(",upd.username updateName ");
    sql.append(" from chf_ocean o ");
    sql.append(" inner join sys_user suser on suser.user_id=o.create_user ");
    sql.append(" left join sys_user upd on upd.user_id=o.update_user ");
    sql.append(" left join chf_bill_ocean_apply boa on boa.ocean_id=o.id ");
    sql.append(" inner join sys_organization sogzn on sogzn.organization_id=o.organization_id and sogzn.deleted=0 ");
		if (Utils.isNotEmpty(ocean.getKeywords())) {
			sql.append(" left join chf_ocean_process op on op.ocean_id=o.id ");
		}
    sql.append(" where o.deleted=0 ");
		if(loginUser.getUserId() != UserConstant.ADMIN_ID){
      sql.append(" and o.organization_id=:tableOrganizationId ");
      map.put("tableOrganizationId", loginUser.getOrganizationId() + "");
    }

    if(Utils.isNotEmpty(ocean)){
			if (Utils.isNotEmpty(ocean.getKeywords())) {
				sql.append(" and op.state=:keywords ");
				map.put("keywords", ocean.getKeywords());
			}
			if(Utils.isNotEmpty(ocean.getBillOfLading())){
				sql.append(" and instr(o.bill_of_lading,:bill_of_lading)>0 ");
				map.put("bill_of_lading", ocean.getBillOfLading());
			}
			if(Utils.isNotEmpty(ocean.getState())){
				sql.append(" and instr(o.state,:state)>0 ");
				map.put("state", ocean.getState());
			}
			if(Utils.isNotEmpty(ocean.getCustomer())){
				sql.append(" and instr(o.customer,:customer)>0 ");
				map.put("customer", ocean.getCustomer());
			}
			if(Utils.isNotEmpty(ocean.getDate1())){
				sql.append(" and o.create_time>=:date1 ");
				map.put("date1", ocean.getDate1());
			}
			if(Utils.isNotEmpty(ocean.getDate2())){
				sql.append(" and o.create_time<=:date2 ");
				map.put("date2", ocean.getDate2());
			}
			/*if(Utils.isNotEmpty(ocean.getDate1())){
				sql.append(" and o.goShipDay>=:date1 ");
				map.put("date1", ocean.getDate1());
			}
			if(Utils.isNotEmpty(ocean.getDate2())){
				sql.append(" and o.goShipDay<=:date2 ");
				map.put("date2", ocean.getDate2());
			}
			if(Utils.isNotEmpty(ocean.getDate3())){
				sql.append(" and o.cut_off_day>=:date3 ");
				map.put("date3", ocean.getDate3());
			}
			if(Utils.isNotEmpty(ocean.getDate4())){
				sql.append(" and o.cut_off_day<=:date4 ");
				map.put("date4", ocean.getDate4());
			}*/
      if(Utils.isNotEmpty(ocean.getSort())&&Utils.isNotEmpty(ocean.getOrder())){
        sql.append(" order by o."+ocean.getSort()+" "+ocean.getOrder());
      } else {
        sql.append(" order by o.create_time desc");
      }
		}
		return jsonResult(getPageQueryList(page, sql.toString(), map, rm));
	}

	@Override
	public JsonResult listDel(PageResult2<T> page, Ocean ocean, User loginUser) throws Exception {
		Map<String, String> map  = new HashMap<String, String>();
		RowMapper<Ocean> rm = new BeanPropertyRowMapper<Ocean>(Ocean.class);
		StringBuffer sql = new StringBuffer("select o.id,o.organization_id,o.pre_configuration_id,o.customer_id");
    sql.append(",o.customer,o.contacts,o.contacts_phone,o.start_port");
		sql.append(",o.end_port,o.box_type,o.go_ship_day,o.vessel");
		sql.append(",o.voyage,o.air_route,o.bill_of_lading,o.booking_agent,o.ship");
		sql.append(",o.deliver,o.box_num,o.sealno,o.cut_off_day,o.cut_off_annex,o.cut_order_annex,o.finish_ocean_day,o.customer_remark");
		sql.append(",o.plat_remark,o.finance_remark,o.state,o.book_annex");
		sql.append(",o.cus_plan_deposit,o.pre_storage_deposit,o.settlement_date,o.payment_type");
		sql.append(",o.release_annex,o.salesmanId,o.salesman,o.operatorId");
		sql.append(",o.operator,o.create_time,o.create_user,o.update_time");
		sql.append(",o.update_user");
		sql.append(",boa.bill_id,boa.apply_id");
    sql.append(",sogzn.organization_name organizationName,suser.nick_name createName ");
    sql.append(",upd.username updateName ");
    sql.append(" from chf_ocean o ");
    sql.append(" inner join sys_user suser on suser.user_id=o.create_user ");
    sql.append(" left join sys_user upd on upd.user_id=o.update_user ");
    sql.append(" left join chf_bill_ocean_apply boa on boa.ocean_id=o.id ");
    sql.append(" inner join sys_organization sogzn on sogzn.organization_id=o.organization_id and sogzn.deleted=0 ");
    sql.append(" where o.deleted=1 ");
		if(loginUser.getUserId() != UserConstant.ADMIN_ID){
      sql.append(" and o.organization_id=:tableOrganizationId ");
      map.put("tableOrganizationId", loginUser.getOrganizationId() + "");
    }
    if(Utils.isNotEmpty(ocean)){
			if(Utils.isNotEmpty(ocean.getBillOfLading())){
				sql.append(" and instr(o.bill_of_lading,:bill_of_lading)>0 ");
				map.put("bill_of_lading", ocean.getBillOfLading());
			}
			if(Utils.isNotEmpty(ocean.getState())){
				sql.append(" and instr(o.state,:state)>0 ");
				map.put("state", ocean.getState());
			}
			if(Utils.isNotEmpty(ocean.getCustomer())){
				sql.append(" and instr(o.customer,:customer)>0 ");
				map.put("customer", ocean.getCustomer());
			}
			if(Utils.isNotEmpty(ocean.getDate1())){
				sql.append(" and o.create_time>=:date1 ");
				map.put("date1", ocean.getDate1());
			}
			if(Utils.isNotEmpty(ocean.getDate2())){
				sql.append(" and o.create_time<=:date2 ");
				map.put("date2", ocean.getDate2());
			}
			/*if(Utils.isNotEmpty(ocean.getDate1())){
				sql.append(" and o.goShipDay>=:date1 ");
				map.put("date1", ocean.getDate1());
			}
			if(Utils.isNotEmpty(ocean.getDate2())){
				sql.append(" and o.goShipDay<=:date2 ");
				map.put("date2", ocean.getDate2());
			}
			if(Utils.isNotEmpty(ocean.getDate3())){
				sql.append(" and o.cut_off_day>=:date3 ");
				map.put("date3", ocean.getDate3());
			}
			if(Utils.isNotEmpty(ocean.getDate4())){
				sql.append(" and o.cut_off_day<=:date4 ");
				map.put("date4", ocean.getDate4());
			}*/
      if(Utils.isNotEmpty(ocean.getSort())&&Utils.isNotEmpty(ocean.getOrder())){
        sql.append(" order by o."+ocean.getSort()+" "+ocean.getOrder());
      } else {
        sql.append(" order by o.create_time desc");
      }
		}
		return jsonResult(getPageQueryList(page, sql.toString(), map, rm));
	}

	@Override
	public List<Ocean> list(Ocean ocean, User loginUser) {
		Map<String, String> map  = new HashMap<String, String>();
		RowMapper<Ocean> rm = new BeanPropertyRowMapper<Ocean>(Ocean.class);
    StringBuffer sql = new StringBuffer("select o.id,o.organization_id,o.pre_configuration_id,o.customer_id");
    sql.append(",o.customer,o.contacts,o.contacts_phone,o.start_port");
		sql.append(",o.end_port,o.box_type,o.go_ship_day,o.vessel");
		sql.append(",o.voyage,o.air_route,o.bill_of_lading,o.booking_agent,o.ship");
		sql.append(",o.deliver,o.box_num,o.sealno,o.cut_off_day,o.cut_off_annex,o.cut_order_annex,o.finish_ocean_day,o.customer_remark");
		sql.append(",o.plat_remark,o.finance_remark,o.state,o.book_annex");
		sql.append(",o.cus_plan_deposit,o.pre_storage_deposit,o.settlement_date,o.payment_type");
		sql.append(",o.release_annex,o.salesmanId,o.salesman,o.operatorId");
		sql.append(",o.operator,o.create_time,o.create_user,o.update_time");
		sql.append(",o.update_user");
    sql.append(",sogzn.organization_name organizationName,suser.nick_name createName ");
		sql.append(",upd.username updateName ");
    sql.append(" from chf_ocean o ");
    sql.append(" inner join sys_user suser on suser.user_id=o.create_user ");
		sql.append(" left join sys_user upd on upd.user_id=o.update_user ");
    sql.append(" inner join sys_organization sogzn on sogzn.organization_id=o.organization_id and sogzn.deleted=0 ");
    sql.append(" where o.deleted=0 ");
		if(loginUser.getUserId() != UserConstant.ADMIN_ID){
      sql.append(" and o.organization_id=:tableOrganizationId ");
      map.put("tableOrganizationId", loginUser.getOrganizationId() + "");
    }
    if(Utils.isNotEmpty(ocean)){
			if(Utils.isNotEmpty(ocean.getBillOfLading())){
				sql.append(" and instr(o.bill_of_lading,:bill_of_lading)>0 ");
				map.put("bill_of_lading", ocean.getBillOfLading());
			}
			if(Utils.isNotEmpty(ocean.getState())){
				sql.append(" and instr(o.state,:state)>0 ");
				map.put("state", ocean.getState());
			}
			if(Utils.isNotEmpty(ocean.getState())){
				sql.append(" and instr(o.state,:state)>0 ");
				map.put("state", ocean.getState());
			}
			if(Utils.isNotEmpty(ocean.getDate1())){
				sql.append(" and o.create_time>=:date1 ");
				map.put("date1", ocean.getDate1());
			}
			if(Utils.isNotEmpty(ocean.getDate2())){
				sql.append(" and o.create_time<=:date2 ");
				map.put("date2", ocean.getDate2());
			}
      if(Utils.isNotEmpty(ocean.getSort())&&Utils.isNotEmpty(ocean.getOrder())){
        sql.append(" order by o."+ocean.getSort()+" "+ocean.getOrder());
      } else {
        sql.append(" order by o.create_time desc");
      }
    }
		getMapParameter(sql, map);
		return jdbcTemplate.query(sql.toString(),map, rm);
	}

	@Override
	public Ocean getById(Ocean ocean) {
		RowMapper<Ocean> rm = new BeanPropertyRowMapper<Ocean>(Ocean.class);
		Map<String, String> map  = new HashMap<String, String>();
		StringBuffer sql = new StringBuffer("select o.id,o.organization_id,o.pre_configuration_id,o.customer_id");
    sql.append(",o.customer,o.contacts,o.contacts_phone,o.start_port");
		sql.append(",o.end_port,o.box_type,o.go_ship_day,o.vessel");
		sql.append(",o.voyage,o.air_route,o.bill_of_lading,o.booking_agent,o.ship");
		sql.append(",o.deliver,o.box_num,o.sealno,o.cut_off_day,o.cut_off_annex,o.cut_order_annex,o.finish_ocean_day,o.customer_remark");
		sql.append(",o.plat_remark,o.finance_remark,o.state,o.book_annex");
		sql.append(",o.cus_plan_deposit,o.pre_storage_deposit,o.settlement_date,o.payment_type");
		sql.append(",o.release_annex,o.salesmanId,o.salesman,o.operatorId");
		sql.append(",o.operator,o.create_time,o.create_user,o.update_time");
		sql.append(",o.update_user");
    sql.append(",sogzn.organization_name organizationName,suser.nick_name createName ");
		sql.append(",upd.username updateName ");
    sql.append(" from chf_ocean o ");
    sql.append(" inner join sys_user suser on suser.user_id=o.create_user ");
		sql.append(" left join sys_user upd on upd.user_id=o.update_user ");
    sql.append(" inner join sys_organization sogzn on sogzn.organization_id=o.organization_id and sogzn.deleted=0 ");
    sql.append(" where o.deleted=0 and o.id=:id ");
		map.put("id", ocean.getId());
		getMapParameter(sql, map);
		return jdbcTemplate.queryForObject(sql.toString(), map, rm);
	}

	@Override
	public Integer customerOfferTodayNum(Ocean ocean) {
		Map<String, String> map  = new HashMap<String, String>();
		RowMapper<Integer> rm = new SingleColumnRowMapper<Integer>(Integer.class);
		StringBuffer sql = new StringBuffer("select count(1) ");
		sql.append(" from chf_ocean ");
		sql.append(" where deleted=0 and customer_id=:customer_id ");
		sql.append(" and DATE_FORMAT(go_ship_day,'%Y-%m-%d') =DATE_FORMAT(:go_ship_day,'%Y-%m-%d') ");
		map.put("customer_id", ocean.getCustomerId()+"");
		map.put("go_ship_day", ocean.getGoShipDay());
		getMapParameter(sql, map);
		return jdbcTemplate.queryForObject(sql.toString(),map, rm);
	}

	@Override
	public Integer save(Ocean ocean, User loginUser) {
		GeneratedKeyHolder generatedKeyHolder = new GeneratedKeyHolder();
		Map<String, String> map  = new HashMap<String, String>();
		StringBuffer sql =new StringBuffer("insert into chf_ocean (");
    sql.append("organization_id,customer_id,pre_configuration_id,customer,contacts");
		sql.append(",contacts_phone,start_port,end_port,box_type");
		sql.append(",go_ship_day,vessel,voyage,air_route,bill_of_lading");
		sql.append(",booking_agent,ship,deliver,box_num");
		sql.append(",sealno,cut_off_day,cut_off_annex,cut_order_annex,finish_ocean_day,customer_remark,plat_remark,finance_remark");
		sql.append(",cus_plan_deposit,pre_storage_deposit,settlement_date,payment_type");
		sql.append(",state,book_annex,release_annex,salesmanId");
		sql.append(",salesman,operatorId,operator,create_user,create_time) values ( ");
    sql.append(":organization_id,:customer_id,:pre_configuration_id,:customer,:contacts");
		sql.append(",:contacts_phone,:start_port,:end_port,:box_type");
		sql.append(",:go_ship_day,:vessel,:voyage,:air_route,:bill_of_lading");
		sql.append(",:booking_agent,:ship,:deliver,:box_num");
		sql.append(",:sealno,:cut_off_day,:cut_off_annex,:cut_order_annex,:finish_ocean_day,:customer_remark,:plat_remark,:finance_remark");
		sql.append(",:cus_plan_deposit,:pre_storage_deposit,:settlement_date,:payment_type");
		sql.append(",:state,:book_annex,:release_annex,:salesmanId");
		sql.append(",:salesman,:operatorId,:operator,:create_user,now())");
    map.put("organization_id", loginUser.getOrganizationId() + "");
    map.put("pre_configuration_id", ocean.getPreConfigurationId());
    map.put("customer_id", ocean.getCustomerId()+"");
    map.put("customer", ocean.getCustomer());
    map.put("contacts", ocean.getContacts());
    map.put("contacts_phone", ocean.getContactsPhone());
    map.put("start_port", ocean.getStartPort());
    map.put("end_port", ocean.getEndPort());
    map.put("box_type", ocean.getBoxType());
    map.put("go_ship_day", ocean.getGoShipDay());
    map.put("vessel", ocean.getVessel());
    map.put("voyage", ocean.getVoyage());
    map.put("air_route", ocean.getAirRoute());
    map.put("bill_of_lading", ocean.getBillOfLading());
    map.put("booking_agent", ocean.getBookingAgent());
    map.put("ship", ocean.getShip());
    map.put("deliver", ocean.getDeliver());
    map.put("box_num", ocean.getBoxNum());
    map.put("sealno", ocean.getSealno());
    map.put("cut_off_day", ocean.getCutOffDay());
    map.put("cut_off_annex", ocean.getCutOffAnnex());
    map.put("cut_order_annex", ocean.getCutOrderAnnex());
    map.put("finish_ocean_day", ocean.getFinishOceanDay());
    map.put("customer_remark", ocean.getCustomerRemark());
    map.put("plat_remark", ocean.getPlatRemark());
    map.put("finance_remark", ocean.getFinanceRemark());
    map.put("state", ocean.getState());
    map.put("book_annex", ocean.getBookAnnex());
    map.put("release_annex", ocean.getReleaseAnnex());
    map.put("cus_plan_deposit", ocean.getCusPlanDeposit());
    map.put("pre_storage_deposit", ocean.getPreStorageDeposit());
    map.put("settlement_date", ocean.getSettlementDate());
    map.put("payment_type", ocean.getPaymentType());
    map.put("salesmanId", ocean.getSalesmanId()+"");
    map.put("salesman", ocean.getSalesman());
    map.put("operatorId", ocean.getOperatorId()+"");
    map.put("operator", ocean.getOperator());
		map.put("create_user", loginUser.getUserId() + "");
		getMapParameter(sql, map);
		int retVal = this.jdbcTemplate.update(sql.toString(), new SqlParameterSource() {
			@Override
			public boolean hasValue(String paramName) {
				return map.containsKey(paramName);
			}
			@Override
			public Object getValue(String paramName) throws IllegalArgumentException {
				return map.get(paramName);
			}
		}, generatedKeyHolder);
		Integer id = generatedKeyHolder.getKey().intValue();
		return id;
	}

	@Override
	public boolean releaseTheCabin(Ocean ocean, User loginUser) {
		Map<String, String> map  = new HashMap<String, String>();
		StringBuffer sql =new StringBuffer("update chf_ocean set ");
		sql.append("vessel=:vessel,voyage=:voyage,bill_of_lading=:bill_of_lading ");
		sql.append(",release_annex=:release_annex,plat_remark=:plat_remark ");
		sql.append(",state=:state,update_time=now() ");
		sql.append(",update_user=:update_user where id=:id ");
		map.put("vessel", ocean.getVessel());
		map.put("voyage", ocean.getVoyage());
		map.put("bill_of_lading", ocean.getBillOfLading());
		map.put("release_annex", ocean.getReleaseAnnex());
		map.put("plat_remark", ocean.getPlatRemark());
		map.put("state", ocean.getState());
		map.put("update_user", loginUser.getUserId() + "");
		map.put("id", ocean.getId());
		getMapParameter(sql, map);
		int count = jdbcTemplate.update(sql.toString(), map);
		return count > 0;
	}

	@Override
	public boolean cutOrder(Ocean ocean, User loginUser) {
		Map<String, String> map  = new HashMap<String, String>();
		StringBuffer sql =new StringBuffer("update chf_ocean set ");
		sql.append("cut_order_annex=:cut_order_annex ");
		sql.append(",finish_ocean_day=:finish_ocean_day ");
		sql.append(",state=:state ");
		sql.append(",update_time=now() ");
		sql.append(",update_user=:update_user where id=:id ");
    map.put("cut_order_annex", ocean.getCutOrderAnnex());
		map.put("finish_ocean_day", ocean.getFinishOceanDay());
    map.put("state", ocean.getState());
		map.put("update_user", loginUser.getUserId() + "");
		map.put("id", ocean.getId());
		getMapParameter(sql, map);
		int count = jdbcTemplate.update(sql.toString(), map);
		return count > 0;
	}

	@Override
	public boolean cutOff(Ocean ocean, User loginUser) {
		Map<String, String> map  = new HashMap<String, String>();
		StringBuffer sql =new StringBuffer("update chf_ocean set ");
		sql.append("cut_off_annex=:cut_off_annex,cut_off_day=:cut_off_day ");
		sql.append(",state=:state ");
		sql.append(",update_time=now() ");
		sql.append(",update_user=:update_user where id=:id ");
    map.put("cut_off_day", ocean.getCutOffDay());
    map.put("cut_off_annex", ocean.getCutOffAnnex());
    map.put("state", ocean.getState());
		map.put("update_user", loginUser.getUserId() + "");
		map.put("id", ocean.getId());
		getMapParameter(sql, map);
		int count = jdbcTemplate.update(sql.toString(), map);
		return count > 0;
	}

	@Override
	public boolean update(Ocean ocean, User loginUser) {
		Map<String, String> map  = new HashMap<String, String>();
		StringBuffer sql =new StringBuffer("update chf_ocean set ");
		sql.append("customer_id=:customer_id,customer=:customer,contacts=:contacts,contacts_phone=:contacts_phone ");
		sql.append(",salesmanId=:salesmanId,salesman=:salesman,operatorId=:operatorId,operator=:operator ");
		sql.append(",cus_plan_deposit=:cus_plan_deposit,pre_storage_deposit=:pre_storage_deposit,settlement_date=:settlement_date,payment_type=:payment_type");
		sql.append(",start_port=:start_port,end_port=:end_port,box_type=:box_type ");
		sql.append(",vessel=:vessel,voyage=:voyage,air_route=:air_route,bill_of_lading=:bill_of_lading");
		sql.append(",booking_agent=:booking_agent,ship=:ship,deliver=:deliver,box_num=:box_num");
		if (Utils.isNotEmpty(ocean.getGoShipDay())) {
			sql.append(",go_ship_day=:go_ship_day");
		}
		if (Utils.isNotEmpty(ocean.getCutOffDay())) {
			sql.append(",cut_off_day=:cut_off_day");
		}
		if (Utils.isNotEmpty(ocean.getFinishOceanDay())) {
			sql.append(",finish_ocean_day=:finish_ocean_day");
		}
		sql.append(",sealno=:sealno,customer_remark=:customer_remark");
		sql.append(",plat_remark=:plat_remark,finance_remark=:finance_remark");
		sql.append(",release_annex=:release_annex ");
		sql.append(",update_time=now() ");
		sql.append(",update_user=:update_user where id=:id ");
		map.put("customer_id", ocean.getCustomerId()+"");
		map.put("customer", ocean.getCustomer());
		map.put("contacts", ocean.getContacts());
		map.put("contacts_phone", ocean.getContactsPhone());
		map.put("salesmanId", ocean.getSalesmanId()+"");
		map.put("salesman", ocean.getSalesman());
		map.put("operatorId", ocean.getOperatorId()+"");
		map.put("operator", ocean.getOperator());
    map.put("start_port", ocean.getStartPort());
    map.put("end_port", ocean.getEndPort());
    map.put("box_type", ocean.getBoxType());
    map.put("vessel", ocean.getVessel());
    map.put("voyage", ocean.getVoyage());
    map.put("air_route", ocean.getAirRoute());
    map.put("bill_of_lading", ocean.getBillOfLading());
    map.put("booking_agent", ocean.getBookingAgent());
    map.put("ship", ocean.getShip());
    map.put("deliver", ocean.getDeliver());
    map.put("box_num", ocean.getBoxNum());
    map.put("sealno", ocean.getSealno());
		if (Utils.isNotEmpty(ocean.getCutOffDay())) {
			map.put("cut_off_day", ocean.getCutOffDay());
		}

		if (Utils.isNotEmpty(ocean.getGoShipDay())) {
			map.put("go_ship_day", ocean.getGoShipDay());
		}
		if (Utils.isNotEmpty(ocean.getFinishOceanDay())) {
			map.put("finish_ocean_day", ocean.getFinishOceanDay());
		}
    map.put("customer_remark", ocean.getCustomerRemark());
    map.put("plat_remark", ocean.getPlatRemark());
    map.put("finance_remark", ocean.getFinanceRemark());
    map.put("book_annex", ocean.getBookAnnex());
    map.put("release_annex", ocean.getReleaseAnnex());
		map.put("cus_plan_deposit", ocean.getCusPlanDeposit());
		map.put("pre_storage_deposit", ocean.getPreStorageDeposit());
		map.put("settlement_date", ocean.getSettlementDate());
		map.put("payment_type", ocean.getPaymentType());
		map.put("update_user", loginUser.getUserId() + "");
		map.put("id", ocean.getId());
		getMapParameter(sql, map);
		int count = jdbcTemplate.update(sql.toString(), map);
		return count > 0;
	}

	@Override
	public boolean remove(Ocean ocean, User loginUser) {
		int count = 0;
		Map<String, String> map = null;
		if(ocean.getId().length()>0){
			for(String ID : ocean.getId().split(",")){
				map  = new HashMap<String, String>();
				if(ID==null || ID.equals("")){ break; }
				StringBuffer sql =new StringBuffer("update chf_ocean set deleted=1" +
						",update_user=:update_user, update_time=now() "
						+ " where id =:id ");
				map.put("update_user", loginUser.getUserId() + "");
				map.put("id", ID);
				getMapParameter(sql, map);
				count = jdbcTemplate.update(sql.toString(),map);
			}
		}
		return count > 0;
	}
}
